import Dialog from '../../../../lib/vant/dialog/dialog';

Page({

  /**
   * 页面的初始数据
   */
  data: {
    szPopupShow: false,//是否显示设置的弹窗
    isPhone: false,//手机号是否输入
    isReceiveSms: false,//是否接收短信
    phone: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  /**
   * 设置
   */
  sz: function(){
    var that = this;
    var szPopupShow = that.data.szPopupShow;
    var newPopupShow = true;
    if (szPopupShow) {
      newPopupShow = false;
    }
    that.setData({
      szPopupShow: newPopupShow
    });
  },

  /**
   * 确定
   */
  submit: function(){
    var that = this;
    that.setData({
      szPopupShow: false
    });
    
    Dialog.alert({
      message: '修改成功',
      showConfirmButton: false,
      overlay: false
    });

    setTimeout(() => {
      Dialog.close();
    }, 1000);
  },
  
  /**
   * 手机号输入事件
   */
  phoneChange: function (e) {
    var that = this;
    if (e.detail.length == 11){
      that.setData({
        isPhone: true,
        phone: e.detail
      });
    }else{
      that.setData({
        isPhone: false,
        phone: e.detail
      });
    }
  },

  /**
   * 是否接收短信
   */
  receiveSms: function(e){
    var that = this;
    var isReceiveSms = that.data.isReceiveSms;
    var da = true;
    if (isReceiveSms) {
      da = false;
    }
    that.setData({
      isReceiveSms: da
    });
  }
})